Skip to contentSkip to conversation

Change in openvpn[master]: dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO ...

Openvpn-devel In review cron2 (Code Review) 2 participants 6 messages Feb 21 – Feb 28 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1771685160000.I84fe7a11391eafde3660d25a3c99094a0c525f3d@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1551?usp=email

to review the following change.

Change subject: dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver
......................................................................

dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver

DCO FreeBSD uses ioctl() calls for userland -> driver communication, on a socket() file descriptor. The original code uses AF_INET sockets, which fails if using a kernel compiled without IPv4 support.

The kernel side ioctl() handling does not differentiate between AF_INET, AF_INET6 and AF_LOCAL sockets, and only the latter are guaranteed to be present.

While add it, add a clear message if the socket() call in dco_available() fails (it will lead to disabling of DCO).

FreeBSD PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286263

Change-Id I84fe7a11391eafde3660d25a3c99094a0c525f3d

---
M src/openvpn/dco_freebsd.c

1 file changed, 3 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/51/1551/1

src/openvpn/dco_freebsd.c +3 -2
index ee3a5d0..718cd8b 100644
@@ -205,7 +205,7 @@
         return -1;
     }
 
-    dco->fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+    dco->fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
     if (dco->fd != -1)
     {
         dco->open = true;
@@ -715,9 +715,10 @@
      * loaded, or built into the kernel. */
     (void)kldload("if_ovpn");
 
-    fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+    fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
     if (fd < 0)
     {
+        msg(M_WARN | M_ERRNO, "%s: socket() failed, disabling data channel offload", __func__);
         return false;
     }
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1551?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I84fe7a11391eafde3660d25a3c99094a0c525f3d
Gerrit-Change-Number: 1551
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos.

ordex has posted comments on this change by cron2. ( http://gerrit.openvpn.net/c/openvpn/+/1551?usp=email )

Change subject: dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver
......................................................................

Patch Set 1: Code-Review+2

(1 comment)

Patchset:

PS1:
I dream of a world where AF_INET6 is the only one guaranteed to exist ;)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1551?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I84fe7a11391eafde3660d25a3c99094a0c525f3d
Gerrit-Change-Number: 1551
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Fri, 27 Feb 2026 22:40:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver

In reply to a message not in the archive

DCO FreeBSD uses ioctl() calls for userland -> driver communication, on a socket() file descriptor. The original code uses AF_INET sockets, which fails if using a kernel compiled without IPv4 support.

The kernel side ioctl() handling does not differentiate between AF_INET, AF_INET6 and AF_LOCAL sockets, and only the latter are guaranteed to be present.

While add it, add a clear message if the socket() call in dco_available() fails (it will lead to disabling of DCO).

FreeBSD PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286263

Change-Id I84fe7a11391eafde3660d25a3c99094a0c525f3d

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1551
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1551
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Antonio Quartulli <[email protected]...>

src/openvpn/dco_freebsd.c +3 -2
index ee3a5d0..718cd8b 100644
@@ -205,7 +205,7 @@
         return -1;
     }
 
-    dco->fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+    dco->fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
     if (dco->fd != -1)
     {
         dco->open = true;
@@ -715,9 +715,10 @@
      * loaded, or built into the kernel. */
     (void)kldload("if_ovpn");
 
-    fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+    fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
     if (fd < 0)
     {
+        msg(M_WARN | M_ERRNO, "%s: socket() failed, disabling data channel offload", __func__);
         return false;
     }
 
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver

Thanks for the review, thanks to Marek for reporting and testing.

Patch has been applied to the master, release/2.7 and release/2.6 branch (it's something like "long-term compat" and we could argue that FreeBSD will move to 2.7.x really soon now, so this is not needed - but it brings an extra msg() that helps problem diagnosis, and there is a benefit - also the change is very very isolated).

commit 5f19355d15da17cbc70624f833171f162adc4ea4 (master) commit b215499c30581d8b2c5344ea5c4d6b1c25580955 (release/2.7) commit a89186242f49b5cb7ed790f57430b9fc00b8973a (release/2.6)

Author: Gert Doering
Date:   Fri Feb 27 23:47:39 2026 +0100
     dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1551
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg35795.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

Hello ordex, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1551?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review+2 by ordex

Change subject: dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver
......................................................................

dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver

DCO FreeBSD uses ioctl() calls for userland -> driver communication, on a socket() file descriptor. The original code uses AF_INET sockets, which fails if using a kernel compiled without IPv4 support.

The kernel side ioctl() handling does not differentiate between AF_INET, AF_INET6 and AF_LOCAL sockets, and only the latter are guaranteed to be present.

While add it, add a clear message if the socket() call in dco_available() fails (it will lead to disabling of DCO).

FreeBSD PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286263

Change-Id I84fe7a11391eafde3660d25a3c99094a0c525f3d

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1551
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35795.html

---
M src/openvpn/dco_freebsd.c

1 file changed, 3 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/51/1551/2

src/openvpn/dco_freebsd.c +3 -2
index ee3a5d0..718cd8b 100644
@@ -205,7 +205,7 @@
         return -1;
     }
 
-    dco->fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+    dco->fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
     if (dco->fd != -1)
     {
         dco->open = true;
@@ -715,9 +715,10 @@
      * loaded, or built into the kernel. */
     (void)kldload("if_ovpn");
 
-    fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+    fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
     if (fd < 0)
     {
+        msg(M_WARN | M_ERRNO, "%s: socket() failed, disabling data channel offload", __func__);
         return false;
     }
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1551?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I84fe7a11391eafde3660d25a3c99094a0c525f3d
Gerrit-Change-Number: 1551
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1551?usp=email )

Change subject: dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver
......................................................................

dco_freebsd: use AF_LOCAL sockets for ioctl() communication with DCO driver

DCO FreeBSD uses ioctl() calls for userland -> driver communication, on a socket() file descriptor. The original code uses AF_INET sockets, which fails if using a kernel compiled without IPv4 support.

The kernel side ioctl() handling does not differentiate between AF_INET, AF_INET6 and AF_LOCAL sockets, and only the latter are guaranteed to be present.

While add it, add a clear message if the socket() call in dco_available() fails (it will lead to disabling of DCO).

FreeBSD PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286263

Change-Id I84fe7a11391eafde3660d25a3c99094a0c525f3d

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1551
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35795.html

---
M src/openvpn/dco_freebsd.c

1 file changed, 3 insertions(+), 2 deletions(-)
src/openvpn/dco_freebsd.c +3 -2
index ee3a5d0..718cd8b 100644
@@ -205,7 +205,7 @@
         return -1;
     }
 
-    dco->fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+    dco->fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
     if (dco->fd != -1)
     {
         dco->open = true;
@@ -715,9 +715,10 @@
      * loaded, or built into the kernel. */
     (void)kldload("if_ovpn");
 
-    fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+    fd = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
     if (fd < 0)
     {
+        msg(M_WARN | M_ERRNO, "%s: socket() failed, disabling data channel offload", __func__);
         return false;
     }
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1551?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I84fe7a11391eafde3660d25a3c99094a0c525f3d
Gerrit-Change-Number: 1551
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>